Method for exchanging time synchronization packet and network apparatus

ABSTRACT

A method for exchanging a clock synchronization packet performed by a network apparatus, including: exchanging a clock synchronization packet with a first clock source, where the network apparatus includes a boundary clock; determining a first time deviation of the boundary clock relative to the first clock source according to the clock synchronization packet exchanged with the first clock source, where the boundary clock avoids performing an operation of calibrating a time of a local clock of the boundary clock according to the first time deviation; and sending a clock synchronization packet to a first slave clock of the boundary clock, where the clock synchronization packet includes a first timestamp, a value of the first timestamp is equal to a first corrected value, and the first corrected value is a value obtained by the boundary clock by correcting the time of the local clock by using the first time deviation.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of International Application No.PCT/CN2016/113847, filed on Dec. 30, 2016, the disclosure of which ishereby incorporated by reference in its entirety.

TECHNICAL FIELD

Embodiments of the present invention relate to the field ofcommunications technologies, and in particular, to a method forexchanging a time synchronization packet and a network apparatus.

BACKGROUND

A clock synchronization network may include multiple networkapparatuses. For example, a clock synchronization network based on theIEEE1588-2008 issued by the Institute of Electrical and ElectronicsEngineers (IEEE) may include a transparent clock (TC), a boundary clock(BC), and an ordinary clock (OC). For example, the BC is a networkapparatus of the clock synchronization network. Before the BC calibratesa time and a frequency of a local clock of a target device, the BC needsto calibrate a time and a frequency of a local clock of the BC accordingto a clock source. When the BC calibrates the time and the frequency ofthe local clock of the BC according to the clock source, the clocksource functions as a master clock (MC), and the BC functions as a slaveclock (SC). When the BC calibrates the time and the frequency of thelocal clock of the target device, the BC functions as a master clock,and the target device functions as a slave clock.

Before a network apparatus calibrates a time or a frequency of a targetdevice, the network apparatus needs to calibrate a time or a frequencyof the network apparatus according to a clock source. Thisimplementation is not flexible enough, and limits an applicationscenario of the network apparatus.

SUMMARY

Embodiments of the present invention provide a method for exchanging atime synchronization packet and a network apparatus, to help extend anapplication scenario of the network apparatus.

According to a first aspect, a method for exchanging a timesynchronization packet is provided, including:

exchanging, by a network apparatus, a clock synchronization packet witha first clock source by using a first slave port, where the networkapparatus includes a BC, and the BC includes the first slave port and afirst master port;

determining, by the network apparatus, a first time deviation of the BCrelative to the first clock source according to the clocksynchronization packet exchanged with the first clock source, where theBC avoids performing an operation of calibrating a time of a local clockof the BC according to the first time deviation; and

sending, by the network apparatus, a clock synchronization packet to afirst slave clock of the BC by using the first master port, where theclock synchronization packet sent by the network apparatus to the firstslave clock includes a first timestamp generated by the BC, a value ofthe first timestamp is equal to a first corrected value, and the firstcorrected value is a value obtained by the BC by correcting a time t1 ofthe local clock by using the first time deviation, where the time t1 isa time at which the BC generates the first timestamp.

In the foregoing technical solution, before the network apparatus isused as a master clock to send a time synchronization packet to a targetdevice, the network apparatus does not need to calibrate a time or afrequency of the network apparatus according to a clock source. Animplementation of the network apparatus is relatively flexible, helpingextend an application scenario of the network apparatus.

Optionally, in the foregoing technical solution, after the exchanging,by a network apparatus, a clock synchronization packet with a firstclock source by using a first slave port, and before the sending, by thenetwork apparatus, a clock synchronization packet to a first slave clockof the BC by using the first master port, the method further includes:

determining, by the network apparatus, a first frequency deviation ofthe BC relative to the first clock source according to the clocksynchronization packet exchanged with the first clock source, where theBC avoids performing an operation of calibrating a frequency of thelocal clock of the BC according to the first frequency deviation, andthe first corrected value is a value obtained by the BC by correcting t1by using the first time deviation and the first frequency deviation.

Optionally, in the foregoing technical solution, the first correctedvalue is equal to a sum of t1, the first time deviation, and a firstphase deviation, and the first phase deviation is a phase deviation thatis of the local clock relative to the first clock source and that iscaused by the first frequency deviation within duration from a time atwhich the local clock determines the first frequency deviation to thetime at which the BC generates the first timestamp.

Optionally, in the foregoing technical solution, the method furtherincludes:

exchanging, by the network apparatus, a clock synchronization packetwith a second clock source by using a second slave port, where the BCincludes the second slave port and a second master port;

determining, by the network apparatus, a second time deviation of the BCrelative to the second clock source according to the clocksynchronization packet exchanged with the second clock source, where theBC avoids performing an operation of calibrating the time of the localclock of the BC according to the second time deviation; and

sending, by the network apparatus, a clock synchronization packet to asecond slave clock of the BC by using the second master port, where theclock synchronization packet sent by the network apparatus to the secondslave clock includes a second timestamp generated by the BC, a value ofthe second timestamp is equal to a second corrected value, and thesecond corrected value is a value obtained by correcting a time t2 ofthe local clock by using the second time deviation, where the time t2 isa time at which the BC generates the second timestamp.

Optionally, in the foregoing technical solution, after the exchanging,by the network apparatus, a clock synchronization packet with a secondclock source by using a second slave port, and before the sending, bythe network apparatus, a clock synchronization packet to a second slaveclock of the BC by using the second master port, the method furtherincludes:

determining, by the network apparatus, a second frequency deviation ofthe BC relative to the second clock source according to the clocksynchronization packet exchanged with the second clock source, where theBC avoids performing an operation of calibrating the frequency of thelocal clock of the BC according to the second frequency deviation, andthe second corrected value is a value obtained by the BC by correctingt2 by using the second time deviation and the second frequencydeviation.

Optionally, in the foregoing technical solution, the second correctedvalue is equal to a sum of t2, the second time deviation, and a secondphase deviation, and the second phase deviation is a phase deviationthat is of the local clock relative to the second clock source and thatis caused by the second frequency deviation within duration from a timeat which the local clock determines the second frequency deviation tothe time at which the BC generates the second timestamp.

According to a second aspect, a network apparatus is provided,including:

an interaction unit, configured to exchange a clock synchronizationpacket with a first clock source by using a first slave port, where thenetwork apparatus includes a boundary clock BC, and the BC includes thefirst slave port and a first master port;

a determining unit, configured to determine a first time deviation ofthe BC relative to the first clock source according to the clocksynchronization packet exchanged with the first clock source, where theBC avoids performing an operation of calibrating a time of a local clockof the BC according to the first time deviation; and

a sending unit, configured to send a clock synchronization packet to afirst slave clock of the BC by using the first master port, where theclock synchronization packet sent by the network apparatus to the firstslave clock includes a first timestamp generated by the BC, a value ofthe first timestamp is equal to a first corrected value, and the firstcorrected value is a value obtained by the BC by correcting a time t1 ofthe local clock by using the first time deviation, where the time t1 isa time at which the BC generates the first timestamp.

In the foregoing technical solution, before the network apparatus isused as a master clock to send a time synchronization packet to a targetdevice, the network apparatus does not need to calibrate a time or afrequency of the network apparatus according to a clock source. Animplementation of the network apparatus is relatively flexible, helpingextend an application scenario of the network apparatus.

Optionally, in the foregoing technical solution, the determining unit isfurther configured to:

after the interaction unit exchanges the clock synchronization packetwith the first clock source by using the first slave port, and beforethe sending unit sends the clock synchronization packet to the firstslave clock of the BC by using the first master port,

determine a first frequency deviation of the BC relative to the firstclock source according to the clock synchronization packet exchangedwith the first clock source, where the BC avoids performing an operationof calibrating a frequency of the local clock of the BC according to thefirst frequency deviation, and the first corrected value is a valueobtained by the BC by correcting t1 by using the first time deviationand the first frequency deviation.

Optionally, in the foregoing technical solution,

the interaction unit is further configured to exchange a clocksynchronization packet with a second clock source by using a secondslave port, where the BC includes the second slave port and a secondmaster port;

the determining unit is further configured to determine a second timedeviation of the BC relative to the second clock source according to theclock synchronization packet exchanged with the second clock source,where the BC avoids performing an operation of calibrating the time ofthe local clock of the BC according to the second time deviation; and

the sending unit is further configured to send a clock synchronizationpacket to a second slave clock of the BC by using the second masterport, where the clock synchronization packet sent by the networkapparatus to the second slave clock includes a second timestampgenerated by the BC, a value of the second timestamp is equal to asecond corrected value, and the second corrected value is a valueobtained by correcting a time t2 of the local clock by using the secondtime deviation, where the time t2 is a time at which the BC generatesthe second timestamp.

Optionally, in the foregoing technical solution, the determining unit isfurther configured to:

after the interaction unit exchanges the clock synchronization packetwith the second clock source by using the second slave port, and beforethe sending unit sends the clock synchronization packet to the secondslave clock of the BC by using the second master port,

determine a second frequency deviation of the BC relative to the secondclock source according to the clock synchronization packet exchangedwith the second clock source, where the BC avoids performing anoperation of calibrating the frequency of the local clock of the BCaccording to the second frequency deviation, and the second correctedvalue is a value obtained by the BC by correcting t2 by using the secondtime deviation and the second frequency deviation.

According to a third aspect, a method for exchanging a clocksynchronization packet is provided, including:

exchanging, by a network apparatus, a clock synchronization packet witha first clock source;

exchanging, by the network apparatus, a clock synchronization packetwith a second clock source;

after the network apparatus exchanges the clock synchronization packetwith the first clock source and after the network apparatus exchangesthe clock synchronization packet with the second clock source, sending,by the network apparatus, a first clock synchronization packet to afirst slave clock of the network apparatus, where the first clocksynchronization packet carries a first timestamp generated by thenetwork apparatus, and a time indicated by the first timestamp is equalto a time that is of the first clock source and at which the networkapparatus sends the first clock synchronization packet; and

after the network apparatus exchanges the clock synchronization packetwith the first clock source and after the network apparatus exchangesthe clock synchronization packet with the second clock source, sending,by the network apparatus, a second clock synchronization packet to asecond slave clock of the network apparatus, where the first clocksynchronization packet carries a second timestamp generated by thenetwork apparatus, and a time indicated by the second timestamp is equalto a time that is of the second clock source and at which the networkapparatus sends the second clock synchronization packet.

In the foregoing technical solution, the network apparatus may transferclock signals of multiple clock domains to a slave clock of the networkapparatus, thereby helping extend an application scenario of the networkapparatus.

Optionally, in the foregoing technical solution, a value of the firsttimestamp is determined in the following manner:

after the network apparatus exchanges the clock synchronization packetwith the first clock source, determining, by the network apparatus, afirst time deviation of the network apparatus relative to the firstclock source according to the clock synchronization packet exchangedwith the first clock source, where the network apparatus avoidsperforming an operation of calibrating a time of a local clock of thenetwork apparatus according to the first time deviation; and

determining, by the network apparatus, that the value of the firsttimestamp is equal to a first corrected value, where the first correctedvalue is a value obtained by the network apparatus by correcting a timet1 of the local clock by using the first time deviation, where the timet1 is a time at which the network apparatus generates the firsttimestamp.

Optionally, in the foregoing technical solution, the value of the firsttimestamp is specifically determined in the following manner:

after the network apparatus exchanges the clock synchronization packetwith the first clock source, determining, by the network apparatus, afirst frequency deviation of the network apparatus relative to the firstclock source according to the clock synchronization packet exchangedwith the first clock source, where the network apparatus avoidsperforming an operation of calibrating a frequency of the local clockaccording to the first frequency deviation; and

determining, by the network apparatus, that the value of the firsttimestamp is equal to the first corrected value, where the firstcorrected value is a value obtained by the network apparatus bycorrecting t1 by using the first time deviation and the first frequencydeviation.

Optionally, in the foregoing technical solution, the first correctedvalue is equal to a sum of t1, the first time deviation, and a firstphase deviation, and the first phase deviation is a phase deviation thatis of the local clock relative to the first clock source and that iscaused by the first frequency deviation within duration from a time atwhich the local clock determines the first frequency deviation to thetime at which the network apparatus generates the first timestamp.

According to a fourth aspect, a network apparatus is provided,including:

a first interaction unit, configured to exchange a clock synchronizationpacket with a first clock source;

a second interaction unit, configured to exchange a clocksynchronization packet with a second clock source;

a first sending unit, configured to: after the first interaction unitexchanges the clock synchronization packet with the first clock sourceand after the second interaction unit exchanges the clocksynchronization packet with the second clock source, send a first clocksynchronization packet to a first slave clock of the network apparatus,where the first clock synchronization packet carries a first timestampgenerated by the network apparatus, and a time indicated by the firsttimestamp is equal to a time that is of the first clock source and atwhich the network apparatus sends the first clock synchronizationpacket; and

a second sending unit, configured to: after the first interaction unitexchanges the clock synchronization packet with the first clock sourceand after the second interaction unit exchanges the clocksynchronization packet with the second clock source, send a second clocksynchronization packet to a second slave clock of the network apparatus,where the first clock synchronization packet carries a second timestampgenerated by the network apparatus, and a time indicated by the secondtimestamp is equal to a time that is of the second clock source and atwhich the network apparatus sends the second clock synchronizationpacket.

In the foregoing technical solution, the network apparatus may transferclock signals of multiple clock domains to a slave clock of the networkapparatus, thereby helping extend an application scenario of the networkapparatus.

Optionally, in the foregoing technical solution, the network apparatusfurther includes a determining unit, where

the determining unit is configured to: after the first interaction unitexchanges the clock synchronization packet with the first clock source,determine a first time deviation of the network apparatus relative tothe first clock source according to the clock synchronization packetexchanged with the first clock source, where the network apparatusavoids performing an operation of calibrating a time of a local clock ofthe network apparatus according to the first time deviation; and

the determining unit is further configured to determine that a value ofthe first timestamp is equal to a first corrected value, where the firstcorrected value is a value obtained by the network apparatus bycorrecting a time t1 of the local clock by using the first timedeviation, where the time t1 is a time at which the network apparatusgenerates the first timestamp.

Optionally, in the foregoing technical solution, the determining unit isfurther configured to: after the first interaction unit exchanges theclock synchronization packet with the first clock source, determine afirst frequency deviation of the network apparatus relative to the firstclock source according to the clock synchronization packet exchangedwith the first clock source, where the network apparatus avoidsperforming an operation of calibrating a frequency of the local clockaccording to the first frequency deviation, and the first correctedvalue is a value obtained by the network apparatus by correcting t1 byusing the first time deviation and the first frequency deviation.

Optionally, in the foregoing technical solution, the first correctedvalue is equal to a sum of t1, the first time deviation, and a firstphase deviation, and the first phase deviation is a phase deviation thatis of the local clock relative to the first clock source and that iscaused by the first frequency deviation within duration from a time atwhich the local clock determines the first frequency deviation to thetime at which the network apparatus generates the first timestamp.

According to a fifth aspect, a system is provided. The system includes anetwork apparatus, a first clock source, and a first slave clock. Thenetwork apparatus in the system is the network apparatus provided in thesecond aspect. The first clock source in the system is the first clocksource mentioned in the second aspect. The first slave clock in thesystem is the first slave clock mentioned in the second aspect.

Optionally, in the technical solutions provided in the first to thefifth aspects, the network apparatus specifically determines the firsttime deviation or the second time deviation according to theIEEE1588-2008.

Optionally, in the technical solutions provided in the first to thefifth aspects, the network apparatus specifically determines the firsttime deviation and the second time deviation according to theIEEE1588-2008.

Optionally, in the technical solutions provided in the first to thefifth aspects, the network apparatus specifically determines the firstfrequency deviation or the second frequency deviation according to theIEEE1588-2008.

Optionally, in the technical solutions provided in the first to thefifth aspects, the network apparatus specifically determines the firstfrequency deviation and the second frequency deviation according to theIEEE1588-2008.

Optionally, in the technical solutions provided in the first to thefifth aspects, the first slave clock calibrates a time of the firstslave clock and/or a frequency of the first slave clock according to thetime synchronization packet sent by the network apparatus to the firstslave clock.

Optionally, in the technical solutions provided in the first to thefifth aspects, the second slave clock calibrates a time of the secondslave clock and/or a frequency of the second slave clock according tothe time synchronization packet sent by the network apparatus to thesecond slave clock.

Optionally, in the technical solutions provided in the first to thefifth aspects, before the network apparatus exchanges the clocksynchronization packet with the first clock source, the networkapparatus calibrates the time and/or the frequency of the boundary clockaccording to a BITS clock.

Optionally, in the technical solutions provided in the first to thefifth aspects, before the network apparatus exchanges the clocksynchronization packet with the second clock source, the networkapparatus calibrates the time and/or the frequency of the boundary clockaccording to a BITS clock.

BRIEF DESCRIPTION OF DRAWINGS

To describe the technical solutions in the embodiments of thisapplication more clearly, the following briefly describes theaccompanying drawings required for describing the embodiments.Apparently, the accompanying drawings in the following descriptionmerely show some embodiments of this application, and a person ofordinary skill in the art can derive other drawings from theseaccompanying drawings without creative efforts.

FIG. 1 is a schematic diagram of a clock synchronization networkaccording to an embodiment;

FIG. 2 is a schematic diagram of a clock synchronization networkaccording to an embodiment;

FIG. 3 is a schematic flowchart of a method according to an embodiment;

FIG. 4 is a schematic structural diagram of a network apparatusaccording to an embodiment;

FIG. 5 is a schematic structural diagram of a network apparatusaccording to an embodiment;

FIG. 6 is a schematic flowchart of a method for exchanging a clocksynchronization packet according to an embodiment;

FIG. 7 is a schematic structural diagram of a network apparatusaccording to an embodiment; and

FIG. 8 is a schematic structural diagram of a system according to anembodiment.

DESCRIPTION OF EMBODIMENTS

The following describes the technical solutions in the embodiments ofthe present invention with reference to the accompanying drawings in theembodiments of the present invention.

In the embodiments, a local clock of a network apparatus is a clockincluded in the network apparatus. The clock is capable of performing atiming function. For example, the clock may include a crystal oscillatorand a counter. The counter may be specifically an accumulator. Thecounter may include a memory. A value stored in the memory is equal to acurrent time recorded by the clock. The crystal oscillator may output,in each working cycle, a pulse signal to the counter. When the counterdetects a rising edge or a falling edge of the pulse signal, the counterperforms an addition operation on an increment and the value stored inthe memory, so as to update the value stored in the memory. Theincrement is equal to a nominal working cycle of the crystal oscillator.For example, a nominal working frequency of the crystal oscillator maybe 125 Mega Hertz (MHz). Correspondingly, the nominal working cycle ofthe crystal oscillator may be 8 nanoseconds. At a time, the clock mayhave a time deviation and a frequency deviation relative to a clocksource. After specified duration, the current time recorded by the clockmay be not accurate enough. Both the time deviation and the frequencydeviation may cause the current time to be not accurate enough. Thefollowing describes a case in which the current time is not accurateenough due to the frequency deviation: A deviation exists between thenominal working cycle of the crystal oscillator and an actual workingcycle of the crystal oscillator, and after the counter updates the valuestored in the memory, the current time recorded by the clock may be notaccurate enough. The following describes a case in which the currenttime is not accurate enough due to the time deviation: Before thecounter updates the value stored in the memory, the value stored in thememory may not be accurate enough. As a result, the current timerecorded by the clock is not accurate enough after the counter updatesthe value stored in the memory.

The network apparatus including the clock may perform another functionby using the timing function provided by the local clock of the networkapparatus. For example, when the network apparatus sends a packet toanother network apparatus, the network apparatus may add a timestamp tothe to-be-sent packet. The added timestamp is used to indicate a sendingtime of the packet. A value of the added timestamp may be equal to thecurrent time recorded by the local clock. For another example, when thenetwork apparatus receives a packet sent by another network apparatus,the network apparatus may add a timestamp to the received packet. Theadded timestamp is used to indicate a receiving time of the packet. Avalue of the added timestamp may be equal to the current time recordedby the local clock.

It may be understood that each network apparatus may include its ownlocal clock. Local clocks included in different network apparatuses mayhave different precision. In addition, a clock with relatively highprecision in a network apparatus may be used as a master clock tocalibrate a clock with relatively low precision in a network apparatus.The calibrated clock of the network apparatus functions as a slaveclock. For example, a clock of a network apparatus may be used tocalibrate a clock of another network apparatus according to theIEEE1588-2008.

In the embodiments, a physical layer device (PHY device) is a circuitconfigured to implement a function of a physical layer defined in theEthernet protocol. For example, the physical layer may include aphysical coding sublayer (PCS). In addition, the PHY device may performfunctions of generating a timestamp and adding the timestamp to a clocksynchronization packet. The PHY device may include a circuit configuredto perform a function defined in the IEEE1588-2008. For example, whenthe PHY device receives a clock synchronization packet, the PHY devicemay generate, according to a current time of a network apparatus onwhich the PHY device is located, a timestamp used to indicate areceiving time of the clock synchronization packet, and add thetimestamp to the clock synchronization packet. For an Ethernet port, thephysical layer, and the PCS, refer to a description in the Ethernetprotocol. The Ethernet protocol may be the IEEE 802.3ab.

FIG. 1 is a schematic diagram of a clock synchronization networkaccording to an embodiment. The clock synchronization network includes asatellite 10, a router 11, a router 12, a router 13, and a base station16. The satellite 10 may be a GPS satellite. The router 11 may be aprovider router. The router 12 may be a provider edge router. The router13 may be a customer edge router. The router 11, the router 12, and therouter 13 may provide a virtual private network (VPN) service. Forexample, the VPN service may be a layer 2 virtual private network(L2VPN) service. It may be understood that, when the router 11, therouter 12, and the router 13 provide the L2VPN service, another networkelement not shown in FIG. 1 is further included, for example, a host.The host may be a laptop computer or a desktop computer. The basestation 15 is a network element in a cellular network. For example, thebase station 16 may be a Node B. The base station 16 may provide a radioaccess service. It may be understood that, when the base station 16provides the radio access service, another network element not shown inFIG. 1 is further included, for example, user equipment (UE). The userequipment may be a cellular phone.

The satellite 10 may perform a clock synchronization operation on therouter 11. Specifically, the router 11 may include a Global PositioningSystem (GPS) receiver and a clock. The satellite 10 may be a GPSsatellite. The satellite 10 may include an atomic clock. Driven by theatomic clock, the satellite 10 may send a GPS signal to the router 11.The GPS signal may include time data whose precision is the same as thatof the atomic clock. After receiving the GPS signal, the GPS receiver inthe router 11 may synchronize the clock of the router 11 to the atomicclock of the GPS satellite according to the time data in the GPS signal.Specifically, a time of the clock of the router 11 is synchronized to atime of the atomic clock of the GPS satellite. In addition, a frequencyof the clock of the router 11 is synchronized to a frequency of theatomic clock of the GPS satellite. In the foregoing process, the GPSsatellite functions as a master clock, and the router 11 functions as aslave clock. In another implementation, the network shown in FIG. 1 mayfurther include a primary reference time clock (PRTC). The PRTC iscoupled to the router 11. The satellite 10 may perform a clocksynchronization operation on the PRTC to calibrate a time and afrequency of the PRTC. After the time and the frequency of the PRTC arecalibrated, the time and the frequency of the clock of the router 11 maybe calibrated based on the IEEE1588-2008. The PRTC and the router 11 aredevices compliant with the IEEE1588-2008. After the clock of the router11 is calibrated, the router 11 may be used as a grandmaster clock tocalibrate a time of another device.

After the clock of the router 11 is calibrated, the router 11 may beused as a clock source of another device. Specifically, the router 11may be used as a master clock to calibrate a clock of the anotherdevice. For example, both the router 11 and the router 12 may be devicescompliant with the IEEE1588-2008. The router 11 may calibrate, based onthe IEEE1588-2008, a time and frequency of a clock of the router 12.Similarly, the router 12 may be used as a master clock to calibrate aclock of the router 13. The router 13 may be used as a master clock tocalibrate a clock of the base station 16. In the foregoing process, therouter 12 may be considered as a clock source of the router 13.

In the foregoing solution, the router 11, the router 12, and the router13 are located in a fixed network. The base station 16 is located in thecellular network. The router 13 may be at an edge of the fixed network.The router 13 may be a boundary clock. Before the router 13 calibrates atime and a frequency of the local clock of the base station 16, therouter 13 needs to calibrate a time and a frequency of the clock of therouter 13 according to the router 12 that is used as the clock source.

FIG. 2 is a schematic diagram of a clock synchronization networkaccording to an embodiment. A technical solution shown in FIG. 2 may beobtained by means of extension based on the clock synchronizationnetwork shown in FIG. 1. For content not mentioned in this embodiment,refer to the description of the embodiment corresponding to FIG. 1. Thefollowing mainly describes a difference between the technical solutionshown in FIG. 2 and the technical solution shown in FIG. 1. The clocksynchronization network shown in FIG. 2 includes a satellite 10, arouter 11, a router 12, a router 13, a router 14, a router 15, a basestation 16, and a base station 17. Compared with FIG. 1, the clocksynchronization network shown in FIG. 2 further includes the router 14,the router 15, and the base station 17. The router 14 may be a providerrouter. The router 15 may be a provider edge router. The base station 17is a network element in a cellular network.

The satellite 10 may perform a clock synchronization operation on therouter 14. For a process of performing the clock synchronizationoperation on the router 14 by the satellite 10, refer to the foregoingdescription about performing the clock synchronization operation on therouter 11 by the satellite 10. Details are not described herein again.It should be noted that the router 14 may be coupled to a PRTC. A PRTCcoupled to the router 11 and the PRTC coupled to the router 14 may notbe a same PRTC, or may be a same PRTC. The satellite 10 may perform aclock synchronization operation on the PRTC coupled to the router 14, tocalibrate a time and a frequency of the PRTC coupled to the router 14.After the time and the frequency of the PRTC coupled to the router 14are calibrated, the PRTC coupled to the router 14 may calibrate, basedon the IEEE1588-2008, a time and a frequency of a clock of the router14. The PRTC coupled to the router 14 and the router 14 are devicescompliant with the IEEE1588-2008. After the clock of the router 14 iscalibrated, the router 14 may be used as a grandmaster clock tocalibrate a time of another device. For example, the router 14 maycalibrate, based on the IEEE1588-2008, a time and a frequency of a clockof the router 15.

According to FIG. 2, the router 13 and the router 12 are coupled. Therouter 13 and the router 15 are coupled. The router 13 and the basestation 16 are coupled. The router 13 and the base station 17 arecoupled. Specifically, the router 13 includes a port 1, a port 2, a port3, and a port 4. All of the port 1, the port 2, the port 3, and the port4 may be Ethernet ports. The Ethernet port may be compliant with theIEEE 802.3ab protocol. The router 13 may be coupled to the router 12 byusing the port 1. The router 13 may be coupled to the router 15 by usingthe port 2. The router 13 may be coupled to the base station 16 by usingthe port 3. The router 13 may be coupled to the base station 17 by usingthe port 4. The router 13 has two clock sources. One clock source is therouter 12, and the other clock source is the router 15.

Different from the solution shown in FIG. 1, although the router 13 alsoexchanges a time synchronization packet with the router 12, the router13 does not calibrate a time and a frequency of a local clock of therouter 13 according to the time synchronization packet exchanged withthe router 12. In addition, the router 13 may determine a time deviationand a frequency deviation of the router 13 relative to the router 12according to the time synchronization packet exchanged with the router12. The router 13 may generate, according to the time of the local clockof the router 13 and the determined time deviation and frequencydeviation, a clock signal (timestamp) that has same precision as thatgenerated by the router 12. The router 13 adds the timestamp to a clocksynchronization packet, and sends the clock synchronization packet tothe base station 16. Then, the router 13 may calibrate a local clock ofthe base station 16. For the foregoing process, refer to a descriptionin an embodiment corresponding to FIG. 3.

Similarly, the router 13 exchanges a time synchronization packet withthe router 15, but the router 13 does not calibrate the time and thefrequency of the local clock of the router 13 according to the timesynchronization packet exchanged with the router 15. In addition, therouter 13 may determine a time deviation and a frequency deviation ofthe router 13 relative to the router 15 according to the timesynchronization packet exchanged with the router 15. The router 13 maygenerate, according to the time of the local clock of the router 13 andthe determined time deviation and frequency deviation, a clock signal(timestamp) that has same precision as that generated by the router 15.The router 13 adds the timestamp to a clock synchronization packet, andsends the clock synchronization packet to the base station 17. Then, therouter 13 may calibrate a local clock of the base station 17. For theforegoing process, refer to a description in the embodimentcorresponding to FIG. 3.

FIG. 3 is a schematic flowchart of a method according to an embodiment.The method includes S301, S302, and S303. The method shown in FIG. 3 isperformed by a network apparatus. The network apparatus may be a router,a network switch, a firewall, a load balancer, a base station, a packettransport network (PTN) device, a serving GPRS support node (SGSN), agateway GPRS support node (GGSN), a radio network controller (RNC), or abase station controller (BSC). The network apparatus includes a boundaryclock. It may be understood that an operation related to a clock signaland performed by the network apparatus is actually performed by theboundary clock. For example, an operation of adding a timestamp to asent or received packet by the network apparatus is performed by theboundary clock. For another example, that the network apparatusdetermines a time deviation and a frequency deviation of the networkapparatus relative to a clock source according to a clocksynchronization packet exchanged with the clock source is performed bythe boundary clock. FIG. 4 is a schematic structural diagram of aspecific implementation of the network apparatus. Referring to FIG. 4,the network apparatus may include a control board and a forwardingboard. The control board may be coupled to the forwarding board by usinga control channel. The control board includes a receiver, a parser, acentral processing unit, a crystal oscillator, and an accumulator. Thereceiver may receive information from the forwarding board by using thecontrol channel. The receiver is coupled to the parser. The parser iscoupled to the central processing unit. The central processing unitincludes a register. The crystal oscillator is coupled to theaccumulator. The accumulator includes a storage unit. The centralprocessing unit is coupled to the accumulator. The forwarding boardincludes a transceiver 1, a network processor, and a transceiver 2. Thetransceiver 1 is coupled to the network processor. The network processoris coupled to the transceiver 2. The transceiver 1 includes a physicallayer device. The transceiver 2 includes a physical layer device. The BCmay include a circuit configured to perform a timing function, and acircuit configured to add a timestamp. The circuit configured to performthe timing function includes the crystal oscillator and the accumulator.The circuit configured to add the timestamp may include the physicallayer device of the transceiver 1 and the physical layer device of thetransceiver 2.

For example, the router 13 shown in FIG. 2 may be specifically thenetwork apparatus shown in FIG. 4. The port 1 of the router 13 may bespecifically located on the transceiver 1. The port 3 of the router 13may be specifically located on the transceiver 2. A first clock sourcemay be the router 12. The router 13 may exchange a clock synchronizationpacket with the router 12 by using the port 1.

S301. The network apparatus exchanges a clock synchronization packetwith the first clock source by using a first slave port.

The BC includes the first slave port and a first master port. Theboundary clock is a device defined in the Precision Time Protocol (PTP).A slave port is a port defined in the PTP. A master port is a portdefined in the PTP. The PTP may be the IEEE1588-2008 formulated by theIEEE. For example, the network apparatus may be the router 13 in FIG. 2.The first master port may be located on the port 1. The first slave portmay be located on the port 3.

When the network apparatus exchanges clock synchronization with thefirst clock source, the first clock source is a master clock, and thenetwork apparatus is a slave clock. The exchanging, by the networkapparatus, a clock synchronization packet with a first clock sourceincludes: sending, by the network apparatus, a clock synchronizationpacket to the first clock source, and receiving, by the networkapparatus, a clock synchronization packet sent by the first clocksource.

For example, S301 may specifically include: exchanging, by the networkapparatus, the clock synchronization packet with the first clock sourceaccording to the IEEE1588-2008. For example, the first clock sourcesends a Sync message 1 to the network apparatus. The Sync message 1 maycarry a timestamp 1. The timestamp 1 is used to indicate a time at whichthe first clock source sends the Sync message 1.

Referring to FIG. 4, after receiving the Sync message 1, the transceiver1 may forward the Sync message 1 to the parser by using the controlchannel and the receiver. The parser parses the Sync message 1 to obtainthe timestamp 1. When receiving the Sync message 1, the transceiver 1may generate a timestamp 2 according to a time of receiving the Syncmessage 1. Specifically, when the transceiver 1 receives the Syncmessage 1, the physical layer device of the transceiver 1 may determine,by accessing the accumulator, the time of receiving the Sync message 1,and add the timestamp 2 to the Sync message 1. The timestamp 2 is usedto indicate the time at which the network apparatus receives the Syncmessage 1. Responding to the Sync message 1, the network apparatus sendsa Delay_Req message 1 to the first clock source by using the transceiver1. The Delay_Req message 1 carries a timestamp 3. Specifically, when thetransceiver 1 sends the Delay_Req message 1, the physical layer deviceof the transceiver 1 may determine, by accessing the accumulator, a timeof sending the Delay_Req message 1, and add the timestamp 3 to theDelay_Req message 1. The timestamp 3 is used to indicate the time atwhich the boundary clock sends the Delay_Req message 1. Responding tothe Delay_Req message 1, the first clock source sends a Delay_Respmessage 1 to the network apparatus. The Delay_Resp message 1 carries atimestamp 4. The timestamp 4 is used to indicate a time at which thefirst clock source receives the Delay_Req message 1. After receiving theDelay_Resp message 1, the transceiver 1 may forward the Delay_Respmessage 1 to the parser by using the control channel and the receiver.The parser parses the Delay_Resp message 1 to obtain the timestamp 4.

S302. The network apparatus determines a first time deviation of theboundary clock relative to the first clock source according to the clocksynchronization packet exchanged with the first clock source.

The boundary clock avoids performing an operation of calibrating a timeof a local clock of the boundary clock according to the first timedeviation.

S302 may specifically include: determining, by the boundary clock, thefirst time deviation according to the IEEE1588-2008.

For example, in a specific implementation of S302, the first timedeviation may be determined according to the timestamp 1, the timestamp2, the timestamp 3, and the timestamp 4.

Referring to FIG. 4, the central processing unit may determine the firsttime deviation according to the timestamp 1, the timestamp 2, thetimestamp 3, and the timestamp 4. For example, the first time deviationis equal to (timestamp 2−timestamp 1−timestamp 4+timestamp 3)/2. Afterdetermining the first time deviation, the central processing unit maystore the first time deviation in the register of the central processingunit.

It should be pointed out that, according to the IEEE1588-2008, after theboundary clock determines the first time deviation, the boundary clockcalibrates the time of the local clock of the boundary clock accordingto the first time deviation. Different from the IEEE1588-2008, in thisembodiment, the boundary clock avoids performing an operation ofcalibrating the time of the local clock of the boundary clock accordingto the first time deviation. Therefore, the time of the boundary clockis not affected by the first clock source.

S303. The network apparatus sends a clock synchronization packet to afirst slave clock of the boundary clock by using a first master port.

The clock synchronization packet sent by the network apparatus to thefirst slave clock includes a first timestamp generated by the boundaryclock. A value of the first timestamp is equal to a first correctedvalue. The first corrected value is a value obtained by the boundaryclock by correcting a time t1 of the local clock by using the first timedeviation, where the time t1 is a time at which the boundary clockgenerates the first timestamp.

The boundary clock sends the clock synchronization packet to the firstslave clock of the boundary, so that the first slave clock calibrates atime of the first slave clock according to the time synchronizationpacket exchanged with the BC.

Specifically, as a master clock, the boundary clock may perform a clocksynchronization operation on a slave clock of the boundary clock byusing the first master port of the boundary clock.

For example, the boundary clock may perform a clock synchronizationoperation on the first slave clock according to the IEEE1588-2008.

With reference to FIG. 4, the following describes the foregoing clocksynchronization operation by using an example. For example, the basestation 16 shown in FIG. 2 may be specifically the first slave clock.The port 3 may be located on the transceiver 2. The network apparatusshown in FIG. 4 may exchange a time synchronization packet with the basestation 16 by using the transceiver 2, to perform a time synchronizationoperation. The time synchronization operation may include: sending, bythe network apparatus, a Sync message 2 to the first slave clock byusing the transceiver 2. The Sync message 2 may carry a timestamp 1′.The timestamp 1′ is used to indicate a time at which the boundary clocksends the Sync message 2. For example, the first slave clock may includea receiver′ and a parser′. After receiving the Sync message 2, thereceiver′ may forward the Sync message 2 to the parser′. The parser′parses the Sync message 2 to obtain the timestamp 1′. When receiving theSync message 2, the first slave clock may generate a timestamp 2′according to a time of receiving the Sync message 2. The timestamp 2′ isused to indicate the time at which the first slave clock receives theSync message 2. Responding to the Sync message 2, the first slave clocksends a Delay_Req message 2 to the boundary clock. The Delay_Req message2 carries a timestamp 3′. The timestamp 3′ is used to indicate a time atwhich the first slave clock sends the Delay_Req message 2. Responding tothe Delay_Req message 2, the boundary clock sends a Delay_Resp message 2to the first slave clock by using the transceiver 2. The Delay_Respmessage 2 carries a timestamp 4′. The timestamp 4′ is used to indicate atime at which the boundary clock receives the Delay_Req message 2. Afterreceiving the Delay_Resp message 2, the receiver′ may forward theDelay_Resp message 2 to the parser′. The parser′ parses the Delay_Respmessage 2 to obtain the timestamp 4′. The first slave clock maydetermine a time deviation of the first slave clock relative to theboundary clock according to the timestamp 1′, the timestamp 2′, thetimestamp 3′, and the timestamp 4′. For example, a central processingunit of the first slave clock may determine the time deviation of thefirst slave clock relative to the boundary clock. For example, the timedeviation of the first slave clock relative to the boundary clock isequal to (timestamp 2′−timestamp 1′−timestamp 4′+timestamp 3′)/2. Afterdetermining the first time deviation, the central processing unit of thefirst slave clock may calibrate the time of the first slave clockaccording to the foregoing time deviation.

With reference to FIG. 4, the following describes, by using an example,a process in which the network apparatus generates the Sync message 2carrying the timestamp 1′. When the network apparatus sends the Syncmessage 2 by using the transceiver 2, the first master port may add thetimestamp 1′ to the Sync message 2. Specifically, the transceiver 2 mayinclude the first master port. The first master port may be an Ethernetport. The transceiver 2 includes the physical layer device. The physicallayer device of the transceiver 2 may specifically perform an operationof adding the timestamp 1′ to the Sync message 2.

Referring to FIG. 4, an output end of the control board is coupled to aninput end of the accumulator. The storage unit of the accumulator storesa current time recorded by the boundary clock. The crystal oscillatormay send a square wave to the accumulator. The square wave may includemultiple pulse signals. The accumulator may perform an additionoperation each time the accumulator receives a pulse signal. Forexample, a nominal working frequency of the crystal oscillator is 125MHz. Theoretically, the accumulator may receive a pulse signal every 8nanoseconds. When the accumulator detects a rising edge or a fallingedge of a pulse signal, the accumulator performs an addition operationon a value of the time stored in the storage unit and 8 nanoseconds, andupdates, by using an addition result, the time recorded in the storageunit. By means of the foregoing operation, the timing function of thenetwork apparatus is implemented.

The physical layer device of the transceiver 2 may access the registerof the central processing unit and the storage unit of the accumulatorby using the control channel. Specifically, the physical layer device ofthe transceiver 2 may obtain the first time deviation by accessing theregister of the central processing unit. The physical layer device ofthe transceiver 2 may obtain the time of the network apparatus byaccessing the storage unit of the accumulator. The physical layer deviceof the transceiver 2 may correct the time of the network apparatus byusing the first time deviation, to obtain the timestamp 1′. For example,the physical layer device of the transceiver 2 may perform an additionoperation on the first time deviation and the time of the boundaryclock, to obtain the timestamp 1′.

The first corrected value is a value obtained by the boundary clock bycorrecting the time t1 of the local clock by using the first timedeviation, where the time t1 is a time at which the boundary clockgenerates the first timestamp. That is, the network apparatus needs tofirst perform S302 and then perform S303. In addition, the networkapparatus needs to perform S303 according to a result (the first timedeviation) obtained by performing S302. Before the network apparatusperforms S303, the network apparatus may perform multiple interactionswith the first clock source (for example, the router 12). Eachinteraction includes: sending, by the first clock source, a Sync messageto the network apparatus. Responding to the Sync message, the networkapparatus sends a Delay_Req message to the first clock source.Responding to the Delay_Req message, the first clock source sends aDelay_Resp message to the network apparatus. That is, a timesynchronization packet related to each interaction includes a Syncmessage, a Delay_Req message, and a Delay_Resp message. The networkapparatus may obtain one time deviation according to three timesynchronization packets related to each interaction. The networkapparatus may obtain multiple time deviations according to the multipleinteractions. Each interaction is corresponding to a time deviation. Anytwo time deviations of the multiple time deviations may be equal, or maybe not equal. The network apparatus may save the multiple timedeviations. When the network apparatus performs S303, the networkapparatus may determine the first timestamp by using any one of themultiple time deviations. Optionally, the network apparatus may saveonly a latest time deviation that is determined. That is, the networkapparatus may first save a time deviation that is determined during aprevious interaction. When a new time deviation is determined by meansof a current interaction, the time deviation that is determined duringthe previous interaction is updated to the new time deviation. When thenetwork apparatus performs S303, the network apparatus may determine thefirst timestamp by using the latest time deviation. Generally, thelatest time deviation can more accurately reflect a current timedeviation of the network apparatus relative to the first clock source.

Similarly, when the physical layer device of the transceiver 2 receivesthe Delay_Req message 2 from the first slave clock (for example, a basestation 16), the physical layer device of the transceiver 2 may obtain,by accessing the register of the central processing unit, a timedeviation determined by the central processing unit when the physicallayer device of the transceiver 2 receives the Delay_Req message 2. Inaddition, when the physical layer device of the transceiver 2 receivesthe Delay_Req message 2 from the first slave clock, the physical layerdevice of the transceiver 2 may obtain, by accessing the storage unit ofthe accumulator, a time that is of the boundary clock and at which thephysical layer device of the transceiver 2 receives the Delay_Reqmessage 2. The physical layer device of the transceiver 2 may perform anaddition operation on the time deviation and the time of the boundaryblock that are obtained by the physical layer device of the transceiver2 when the physical layer device of the transceiver 2 receives theDelay_Req message 2, to obtain the timestamp 4′.

It can be learned, from the foregoing description, that a value of thetimestamp 1′ is not equal to a time that is of the boundary clock andthat is recorded by the accumulator of the boundary clock when thenetwork apparatus sends the Sync message 2 by using the transceiver 2.Although the network apparatus exchanges the time synchronization packetwith the first clock source and determines the time deviation of thenetwork apparatus relative to the first clock source, the networkapparatus does not calibrate the time of the network apparatus accordingto the first time deviation. Therefore, when the network apparatus sendsthe Sync message 2 by using the transceiver 2, the time that is of thenetwork apparatus and that is recorded by the accumulator of the networkapparatus may be inaccurate. That is, when the network apparatus sendsthe Sync message 2 by using the transceiver 2, a relatively largedifference may exist between the time that is of the network apparatusand that is recorded by the accumulator of the network apparatus and areal value of the time at which the network apparatus sends the Syncmessage 2. In the foregoing technical solution, the value of thetimestamp 1′ is a value obtained by correcting, by using the first timedeviation, the time that is of the network apparatus and that isrecorded by the accumulator of the network apparatus. Therefore, thevalue of the timestamp 1′ may be relatively accurate. That is, apossible difference between the value of the timestamp 1′ and the realvalue of the time at which the network apparatus sends the Sync message2 may be relatively small. In addition, although the network apparatusdoes not calibrate the time of the network apparatus according to thetime synchronization packet exchanged with the first clock source, avalue of a timestamp (for example, the timestamp 1′) generated by thenetwork apparatus is equal to a value of a timestamp that is generatedby the network apparatus according to the time of the boundary clock(for example, a current time recorded by the memory of the accumulator)when the network apparatus calibrates the time of the network apparatusaccording to the time synchronization packet exchanged with the firstclock source. Therefore, in the foregoing solution, the networkapparatus implements a technical effect of transferring a clock signalof the first clock source to a signal of the first slave clock when theboundary clock does not calibrate the time of the network apparatusaccording to the first clock source.

Similarly, a value of the timestamp 4′ is not equal to the time that isof the network apparatus and that is recorded by the accumulator of thenetwork apparatus when the network apparatus receives the Delay_Reqmessage 2 by using the transceiver 2. A value of a timestamp (forexample, the timestamp 4′) generated by the network apparatus is equalto a value of a timestamp that is generated by the network apparatusaccording to the time of the network apparatus (for example, the currenttime recorded by the memory of the accumulator) when the networkapparatus calibrates the time of the network apparatus according to thetime synchronization packet exchanged with the first clock source.Therefore, in the foregoing solution, the network apparatus implements atechnical effect of transferring a clock signal of the first clocksource to a signal of the first slave clock when the network apparatusdoes not calibrate the time of the network apparatus according to thefirst clock source.

Optionally, in the method shown in FIG. 3, after S301 and before S303,the method further includes: determining, by the boundary clock, a firstfrequency deviation of the boundary clock relative to the first clocksource according to the clock synchronization packet exchanged with thefirst clock source.

The network apparatus avoids calibrating a frequency of the local clockof the boundary clock according to the first frequency deviation. Thefirst corrected value is a value obtained by correcting t1 by using thefirst time deviation and the first frequency deviation.

For example, the clock synchronization packet exchanged between thenetwork apparatus and the first clock source includes the Sync message 1and a follow-up message that are sent by the first clock source to thenetwork apparatus according to the IEEE1588-2008. The Sync message 1includes the timestamp 1 generated by the first clock source. Thenetwork apparatus generates the timestamp 2 when receiving the Syncmessage 1. The timestamp 1 is used to indicate the time of sending theSync message 1. The timestamp 2 is used to indicate the time ofreceiving the Sync message 1. The follow-up message includes a timestamp7 generated by the first clock source. The network apparatus generates atimestamp 8 when receiving the follow-up message. The timestamp 7 isused to indicate a time of sending the follow-up message. The timestamp8 is used to indicate a time of receiving the follow-up message.

The central processing unit of the network apparatus may determine thefirst frequency deviation according to the timestamp 1, the timestamp 2,a timestamp 7, and a timestamp 8. For example, the first frequencydeviation is equal to (timestamp 8−timestamp 7−timestamp 2+timestamp1)/(timestamp 7−timestamp 1). After determining the first frequencydeviation, the central processing unit may store the first frequencydeviation in the register of the central processing unit.

It should be pointed out that, according to the IEEE1588-2008, after thenetwork apparatus determines the first frequency deviation, the networkapparatus calibrates the frequency of the local clock of the boundaryclock according to the first frequency deviation. Different from theIEEE1588-2008, in this embodiment, the boundary clock avoids performingan operation of calibrating the frequency of the local clock of theboundary clock according to the first frequency deviation. Therefore,the frequency of the boundary clock is not affected by the first clocksource.

The foregoing technical solution shows that a frequency deviation of thenetwork apparatus relative to the first clock source is the firstfrequency deviation. As time elapses, the first frequency deviationmakes the network apparatus generate a phase deviation relative to thefirst clock source.

For example, the frequency of the network apparatus is higher than afrequency of the first clock source. For example, the frequency of thenetwork apparatus is higher than the frequency of the first clock sourceby 1 (Part Per Million, ppm). It is assumed that duration from a time atwhich the network apparatus determines the first frequency deviation tothe time at which the network apparatus generates the first timestamp is8 milliseconds. Within the duration of 8 milliseconds, due to thefrequency deviation of the network apparatus relative to the first clocksource, the network apparatus generates a phase deviation of 8nanoseconds relative to the first clock source.

The central processing unit of the network apparatus may store the firstfrequency deviation in the register of the central processing unit. Inaddition, the network apparatus may further use the accumulator torecord the phase deviation that is of the network apparatus relative tothe first clock source and that is caused by the frequency deviation ofthe network apparatus relative to the first clock source, andcontinuously update the phase deviation of the network apparatusrelative to the first clock source.

Within the duration from the time at which the network apparatusdetermines the first frequency deviation to the time at which thenetwork apparatus generates the first timestamp, the network apparatusmay not determine another frequency deviation of the network apparatusrelative to the first clock source.

Alternatively, within the duration from the time at which the networkapparatus determines the first frequency deviation to the time at whichthe network apparatus generates the first timestamp, the networkapparatus may perform one or multiple interactions with the first clocksource to exchange a clock synchronization packet. A clocksynchronization packet in each interaction may include a Sync messageand a follow-up message. The network apparatus may determine a newfrequency deviation of the network apparatus relative to the first clocksource according to the clock synchronization packet in eachinteraction.

For example, the time at which the network apparatus determines thefirst frequency deviation is a time 1. The time at which the networkapparatus generates the first timestamp is a time 2. The duration fromthe time at which the network apparatus determines the first frequencydeviation to the time at which the network apparatus generates the firsttimestamp is a difference between the time 2 and the time 1. The networkapparatus exchanges one clock synchronization packet between the time 1and the time 2, and determines a new frequency deviation (a frequencydeviation 1) of the network apparatus relative to the first clock sourceat a time 3. In this case, the phase deviation that is of the localclock relative to the first clock source and that is caused by the firstfrequency deviation within the duration from the time at which the localclock determines the first frequency deviation to the time at which theBC generates the first timestamp includes a first part and a secondpart.

The first part is equal to a phase deviation that is of the networkapparatus relative to the first clock source and that is caused by thefirst frequency deviation within duration from the time 1 to the time 3.The second part is equal to a phase deviation that is of the networkapparatus relative to the first clock source and that is caused by thefrequency deviation 1 within duration from the time 3 to the time 2. Avalue of the first part is equal to (time 3−time 1)×(first frequencydeviation). A value of the second part is equal to (time 2−time3)×(frequency deviation 1).

Optionally, in the foregoing technical solution, the first correctedvalue is equal to a sum of t1, the first time deviation, and a firstphase deviation, and the first phase deviation is the phase deviationthat is of the local clock relative to the first clock source and thatis caused by the first frequency deviation within the duration from thetime at which the local clock determines the first frequency deviationto the time at which the BC generates the first timestamp.

For example, the physical layer device of the transceiver 2 may obtainthe first time deviation, the first frequency deviation, and the phasedeviation from the register of the central processing unit. For example,it is assumed that t1 is equal to 1 minute and 5 seconds past 8 o'clock,the first time deviation is equal to 1 millisecond, and the first phasedeviation is equal to 8 nanoseconds. The first corrected value is equalto 1 minute, 5 seconds, 1 millisecond, and 8 nanoseconds past 8 o'clock.

Optionally, in the foregoing technical solution, the method may furtherinclude:

exchanging, by the network apparatus, a clock synchronization packetwith a second clock source by using a second slave port, where the BCincludes the second slave port and a second master port;

determining, by the network apparatus, a second time deviation of the BCrelative to the second clock source according to the clocksynchronization packet exchanged with the second clock source, where theBC avoids performing an operation of calibrating the time of the localclock of the BC according to the second time deviation; and

sending, by the network apparatus, a clock synchronization packet to asecond slave clock by using the second master port, where the clocksynchronization packet sent by the network apparatus to the second slaveclock includes a second timestamp generated by the BC, a value of thesecond timestamp is equal to a second corrected value, and the secondcorrected value is a value obtained by the boundary clock by correctinga time t2 of the local clock by using the second time deviation, wherethe time t2 is a time at which the BC generates the second timestamp.

The network apparatus sends the clock synchronization packet to thesecond slave clock, so that the second slave clock calibrates a time ofthe second slave clock according to the time synchronization packetexchanged with the network apparatus.

The second clock source and the first clock source are different clocksources. For example, time precision of the first clock source is notequal to time precision of the second clock source, or frequencyprecision of the first clock source is not equal to frequency precisionof the second clock source. Alternatively, time precision of the firstclock source is not equal to time precision of the second clock source,and frequency precision of the first clock source is not equal tofrequency precision of the second clock source.

For example, the router 15 in FIG. 2 may be the second clock source. Therouter 13 may exchange a clock synchronization packet with the router 15by using the port 2. The second master port may be located on the port2. For a process in which the router 13 may exchange the clocksynchronization packet with the router 15 by using the port 2, refer tothe foregoing description about that the boundary clock exchanges theclock synchronization packet with the first clock source. Details arenot described herein again.

For a process in which the network apparatus determines the second timedeviation of the network apparatus relative to the second clock sourceaccording to the clock synchronization packet exchanged with the secondclock source, refer to the foregoing description about that the networkapparatus determines the first time deviation of the network apparatusrelative to the first clock source according to the clocksynchronization packet exchanged with the first clock source. Detailsare not described herein again. It may be understood that the first timedeviation may be equal to the second time deviation, or the first timedeviation may be not equal to the second time deviation. In addition,the second time deviation may be stored in the register of the centralprocessing unit of the network apparatus.

For example, the base station 17 in FIG. 2 may be the second slaveclock. The second slave port may be located on a port 4. The networkapparatus (for example, the router 13) may send a clock synchronizationpacket to the second slave clock (for example, the base station 17) byusing the second master port (for example, the port 4). Therefore, therouter 13 may calibrate a local clock of the base station 17.

Optionally, in the foregoing technical solution, the second correctedvalue is equal to a sum of t2, the second time deviation, and a secondphase deviation, and the second phase deviation is a phase deviationthat is of the local clock relative to the second clock source and thatis caused by a second frequency deviation within duration from a time atwhich the local clock determines the second frequency deviation to thetime at which the BC generates the second timestamp.

For a process of obtaining the second corrected value, refer to theforegoing description about a process of obtaining the first correctedvalue. Details are not described herein again.

In the foregoing technical solution, the first slave clock and thesecond slave clock are different network apparatuses. The networkapparatus may calibrate the time of the first slave clock and the timeof the second slave clock. In addition, although the network apparatusdoes not calibrate the local clock of the network apparatus according tothe first clock source, a timestamp used by the network apparatus tocalibrate the first slave clock is related to the first clock source.The network apparatus and the first clock source are located in a sameclock domain. Similarly, although the network apparatus does notcalibrate the local clock of the network apparatus according to thesecond clock source, a timestamp used by the network apparatus tocalibrate the second slave clock is related to the second clock source.The network apparatus and the second clock source are located in a sameclock domain. That is, the network apparatus may be located in two clockdomains at the same time, and may respectively transfer signals fromdifferent clock domains to the first slave clock and the second slaveclock.

Optionally, the time precision of the first clock source is differentfrom the time precision of the second clock source. The frequencyprecision of the first clock source is different from the frequencyprecision of the second clock source.

Optionally, in the foregoing technical solution, the first slave portand the second slave port are located on a same physical port of thenetwork apparatus, or the first slave port and the second slave port arelocated on different physical ports of the network apparatus.

Optionally, in the foregoing technical solution, the first master portand the second master port are located on a same physical port of thenetwork apparatus, or the first master port and the second master portare located on different physical ports of the network apparatus.

Optionally, in the foregoing technical solution, before the exchanging,by the network apparatus, a clock synchronization packet with a firstclock source by using a first slave port, the method further includes:

calibrating, by the network apparatus, the frequency of the boundaryclock according to a BITS clock.

For example, the BITS clock may be a component of the network apparatus.Alternatively, the BITS clock may be a device independent of the networkapparatus.

FIG. 5 is a schematic structural diagram of a network apparatus 500according to an embodiment of the present invention. Referring to FIG.5, the network apparatus includes: an interaction unit 501, adetermining unit 502, and a sending unit 503. For example, the networkapparatus 500 may be specifically the network apparatus shown in FIG. 4.For a specific implementation of the network apparatus 500, refer to thedescription in the embodiment corresponding to FIG. 4. The networkapparatus 500 specifically performs the method shown in FIG. 3. For aspecific implementation of the network apparatus 500, refer to thedescription in the embodiment corresponding to FIG. 3.

The interaction unit 501 is configured to exchange a clocksynchronization packet with a first clock source by using a first slaveport, where the network apparatus includes a boundary clock BC, and theBC includes the first slave port and a first master port.

For example, the interaction unit 501 may be configured to perform S301.

For example, the interaction unit 501 may specifically include thetransceiver 1 in FIG. 4. For example, the network apparatus 500 may bethe router 13 in FIG. 2. The first slave port may be located on a port1. The first clock source may be the router 12. The router 13 mayexchange a clock synchronization packet with the router 12 by using aport 2.

The determining unit 502 is configured to determine a first timedeviation of the BC relative to the first clock source according to theclock synchronization packet exchanged with the first clock source,where the BC avoids performing an operation of calibrating a time of alocal clock of the BC according to the first time deviation.

For example, the determining unit 502 may be configured to perform S302.

For example, the determining unit 502 may include the central processingunit, the crystal oscillator, and the accumulator in FIG. 4.

The sending unit 503 is configured to send a clock synchronizationpacket to a first slave clock of the BC by using the first master port,where the clock synchronization packet sent by the network apparatus tothe first slave clock includes a first timestamp generated by the BC, avalue of the first timestamp is equal to a first corrected value, andthe first corrected value is a value obtained by the BC by correcting atime t1 of the local clock by using the first time deviation, where thetime t1 is a time at which the BC generates the first timestamp.

For example, the sending unit 503 may be configured to perform S303.

For example, the sending unit 503 may be the transceiver 2 in FIG. 4.For example, the first master port may be located on a port 3. The firstslave clock may be a base station 16. The router 13 may send a clocksynchronization packet to the base station 16 by using the port 3.

Optionally, in the foregoing technical solution, the determining unit502 is further configured to: after the interaction unit 501 exchangesthe clock synchronization packet with the first clock source by usingthe first slave port, and before the sending unit 503 sends the clocksynchronization packet to the first slave clock of the BC by using thefirst master port, determine a first frequency deviation of the BCrelative to the first clock source according to the clocksynchronization packet exchanged with the first clock source, where theBC avoids performing an operation of calibrating a frequency of thelocal clock of the BC according to the first frequency deviation, andthe first corrected value is a value obtained by the BC by correcting t1by using the first time deviation and the first frequency deviation.

Optionally, in the foregoing technical solution, the first correctedvalue is equal to a sum of t1, the first time deviation, and a firstphase deviation, and the first phase deviation is a phase deviation thatis of the local clock relative to the first clock source and that iscaused by the first frequency deviation within duration from a time atwhich the local clock determines the first frequency deviation to thetime at which the BC generates the first timestamp.

Optionally, in the foregoing technical solution, the interaction unit501 is further configured to exchange a clock synchronization packetwith a second clock source by using a second slave port, where the BCincludes the second slave port and a second master port.

The determining unit 502 is further configured to determine a secondtime deviation of the BC relative to the second clock source accordingto the clock synchronization packet exchanged with the second clocksource, where the BC avoids performing an operation of calibrating thetime of the local clock of the BC according to the second timedeviation.

The sending unit 503 is further configured to send a clocksynchronization packet to a second slave clock of the BC by using thesecond master port, where the clock synchronization packet sent by thenetwork apparatus to the second slave clock includes a second timestampgenerated by the BC, a value of the second timestamp is equal to asecond corrected value, and the second corrected value is a valueobtained by correcting a time t2 of the local clock by using the secondtime deviation, where the time t2 is a time at which the BC generatesthe second timestamp.

For example, the second clock source may be a router 15. The secondmaster port may be located on a port 4. The second slave port may belocated on the port 2. The second slave clock may be a base station 17.The router 13 may send a clock synchronization packet to the basestation 17 by using the port 4.

Optionally, in the foregoing technical solution, the determining unit502 is further configured to: after the interaction unit 501 exchangesthe clock synchronization packet with the second clock source by usingthe second slave port, and before the sending unit 503 sends the clocksynchronization packet to the second slave clock of the BC by using thesecond master port, determine a second frequency deviation of the BCrelative to the second clock source according to the clocksynchronization packet exchanged with the second clock source, where theBC avoids performing an operation of calibrating the frequency of thelocal clock of the BC according to the second frequency deviation, andthe second corrected value is a value obtained by the BC by correctingt2 by using the second time deviation and the second frequencydeviation.

Optionally, in the foregoing technical solution, the second correctedvalue is equal to a sum of t2, the second time deviation, and a secondphase deviation, and the second phase deviation is a phase deviationthat is of the local clock relative to the second clock source and thatis caused by the second frequency deviation within duration from a timeat which the local clock determines the second frequency deviation tothe time at which the BC generates the second timestamp.

Optionally, in the foregoing technical solution, the first slave portand the second slave port are located on a same physical port of thenetwork apparatus, or the first slave port and the second slave port arelocated on different physical ports of the network apparatus.

Optionally, in the foregoing technical solution, the first master portand the second master port are located on a same physical port of thenetwork apparatus, or the first master port and the second master portare located on different physical ports of the network apparatus.

Optionally, in the foregoing technical solution, the network apparatusfurther includes a calibration unit. The calibration unit is configuredto: before the interaction unit 501 exchanges the clock synchronizationpacket with the first clock source by using the first slave port,calibrate the frequency of the BC according to a building integratedtiming supply (building integrated timing supply, BITS) clock.

For example, the BITS clock may be a component of the network apparatus.Alternatively, the BITS clock may be a device independent of the networkapparatus.

FIG. 6 is a schematic flowchart of a method for exchanging a clocksynchronization packet according to an embodiment of the presentinvention. The method includes S601, S602, S603, and S604.

The solution shown in FIG. 6 is executed by a network apparatus. Forexample, the network apparatus may be the router 13 shown in FIG. 2.

S601. The network apparatus exchanges a clock synchronization packetwith a first clock source.

For example, the first clock source may be the router 12. The router 13may exchange a clock synchronization packet with the router 12 by usinga port 1.

For example, S601 may be specifically S301 in FIG. 3. For a specificimplementation of S601, refer to the description in the embodimentcorresponding to FIG. 3.

S602. The network apparatus exchanges a clock synchronization packetwith a second clock source.

For example, the second first clock source may be a router 15. Therouter 13 may exchange a clock synchronization packet with the router 15by using a port 2.

S603. The network apparatus sends a first clock synchronization packetto a first slave clock of the network apparatus.

Further, the first slave clock may calibrate a time of the first slaveclock according to a clock synchronization packet (including the firstclock synchronization packet) exchanged with the network apparatus.

For example, the first slave clock may be a base station 16. The router13 may send the first clock synchronization packet to the base station16 by using a port 3.

Specifically, S603 is performed after S601 and S602.

The first clock synchronization packet carries a first timestampgenerated by the network apparatus. A time indicated by the firsttimestamp is equal to a time that is of the first clock source and atwhich the network apparatus sends the first clock synchronizationpacket.

It may be understood that, before the network apparatus sends the firstclock synchronization packet, if the network apparatus has calibrated atime of the network apparatus according to the clock synchronizationpacket exchanged with the first clock source, the time indicated by thefirst timestamp is equal to a time that is of the network apparatus andat which the network apparatus sends the first clock synchronizationpacket.

S604. The network apparatus sends a second clock synchronization packetto a second slave clock of the network apparatus.

Further, the second slave clock may calibrate a time of the second slaveclock according to a clock synchronization packet (including the secondclock synchronization packet) exchanged with the network apparatus.

For example, the second slave clock may be a base station 17. The router13 may send the second clock synchronization packet to the base station17 by using a port 4.

Specifically, S604 is performed after S601 and S602.

The first clock synchronization packet carries a second timestampgenerated by the network apparatus. A time indicated by the secondtimestamp is equal to a time that is of the second clock source and atwhich the network apparatus sends the second clock synchronizationpacket.

It may be understood that, before the network apparatus sends the secondclock synchronization packet, if the network apparatus has calibratedthe time of the network apparatus according to the clock synchronizationpacket exchanged with the second clock source, the time indicated by thesecond timestamp is equal to a time that is of the network apparatus andat which the network apparatus sends the second clock synchronizationpacket.

In the foregoing technical solution, the first slave clock and thesecond slave clock are different network apparatuses. The networkapparatus may calibrate the time of the first slave clock and the timeof the second slave clock. In addition, the network apparatus and thefirst clock source are located in a same clock domain. The networkapparatus and the second clock source are located in a same clockdomain. That is, the network apparatus may be located in two clockdomains at the same time, and may respectively transfer signals fromdifferent clock domains to the first slave clock and the second slaveclock.

Optionally, a value of the first timestamp is determined in thefollowing manner:

after the network apparatus exchanges the clock synchronization packetwith the first clock source, determining, by the network apparatus, afirst time deviation of the network apparatus relative to the firstclock source according to the clock synchronization packet exchangedwith the first clock source, where the network apparatus avoidsperforming an operation of calibrating a time of a local clock of thenetwork apparatus according to the first time deviation; and

determining, by the network apparatus, that the value of the firsttimestamp is equal to a first corrected value, where the first correctedvalue is a value obtained by the network apparatus by correcting a timet1 of the local clock by using the first time deviation, where the timet1 is a time at which the network apparatus generates the firsttimestamp.

For example, for a specific implementation of determining, by thenetwork apparatus, the first time deviation of the network apparatusrelative to the first clock source, refer to the description about theprocess of determining the first time deviation in the embodimentcorresponding to FIG. 3.

For example, for a specific process of determining the first correctedvalue by the network apparatus, refer to the description about theprocess of determining the first corrected value in the embodimentcorresponding to FIG. 3.

Optionally, the value of the first timestamp is specifically determinedin the following manner:

after the network apparatus exchanges the clock synchronization packetwith the first clock source, determining, by the network apparatus, afirst frequency deviation of the network apparatus relative to the firstclock source according to the clock synchronization packet exchangedwith the first clock source, where the network apparatus avoidsperforming an operation of calibrating a frequency of the local clockaccording to the first frequency deviation; and

determining, by the network apparatus, that the value of the firsttimestamp is equal to the first corrected value, where the firstcorrected value is a value obtained by the network apparatus bycorrecting t1 by using the first time deviation and the first frequencydeviation.

For example, for a specific implementation of determining, by thenetwork apparatus, the first frequency deviation of the networkapparatus relative to the first clock source, refer to the descriptionabout the process of determining the first frequency deviation in theembodiment corresponding to FIG. 3.

For example, for a specific process of determining the first correctedvalue by the network apparatus, refer to the description about theprocess of determining the first corrected value in the embodimentcorresponding to FIG. 3.

Optionally, the first corrected value is equal to a sum of t1, the firsttime deviation, and a first phase deviation, and the first phasedeviation is a phase deviation that is of the local clock relative tothe first clock source and that is caused by the first frequencydeviation within duration from a time at which the local clockdetermines the first frequency deviation to the time at which thenetwork apparatus generates the first timestamp.

For a specific implementation of how a frequency deviation causes aphase deviation, refer to the description in the embodimentcorresponding to FIG. 3, especially the description about that 1 ppmcauses a phase deviation of 8 nanoseconds in the embodimentcorresponding to FIG. 3.

Optionally, a value of the second timestamp is determined in thefollowing manner:

after S602, determining, by the network apparatus, a second timedeviation of the network apparatus relative to the second clock sourceaccording to the clock synchronization packet exchanged with the secondclock source, where the network apparatus avoids performing an operationof calibrating the time of the local clock of the network apparatusaccording to the second time deviation; and

determining, by the network apparatus, that the value of the secondtimestamp is equal to a second corrected value, where the secondcorrected value is a value obtained by correcting a time t2 of the localclock by using the second time deviation, where the time t2 is a time atwhich the network apparatus generates the second timestamp.

Optionally, the value of the second timestamp is specifically determinedin the following manner:

after S602, determining, by the network apparatus, a second frequencydeviation of the network apparatus relative to the second clock sourceaccording to the clock synchronization packet exchanged with the secondclock source, where the network apparatus avoids performing an operationof calibrating the frequency of the local clock of the network apparatusaccording to the second frequency deviation; and

determining, by the network apparatus, that the value of the secondtimestamp is equal to the second corrected value, where the secondcorrected value is a value obtained by the network apparatus bycorrecting t2 by using the second time deviation and the secondfrequency deviation.

Optionally, in the foregoing technical solution, the second correctedvalue is equal to a sum of t2, the second time deviation, and a secondphase deviation, and the second phase deviation is a phase deviationthat is of the local clock relative to the second clock source and thatis caused by the second frequency deviation within duration from a timeat which the local clock determines the second frequency deviation tothe time at which the network apparatus generates the second timestamp.

FIG. 7 is a schematic structural diagram of a network apparatusaccording to an embodiment of the present invention. Referring to FIG.7, the network apparatus 700 includes a first interaction unit 701, asecond interaction unit 702, a first sending unit 703, and a secondsending unit 704. The network apparatus 700 may be specifically thenetwork apparatus in the method shown in FIG. 6. Specifically, thenetwork apparatus 700 may perform the method shown in FIG. 6.

The first interaction unit 701 is configured to exchange a clocksynchronization packet with a first clock source.

For example, the first interaction unit 701 may perform S601. For aspecific implementation of the first interaction unit 701, refer to thedescription in the embodiment corresponding to FIG. 6, especially thedescription about S601 in the embodiment corresponding to FIG. 6.

The second interaction unit 702 is configured to exchange a clocksynchronization packet with a second clock source.

For example, the second interaction unit 702 may perform S602. For aspecific implementation of the second interaction unit 702, refer to thedescription in the embodiment corresponding to FIG. 6, especially thedescription about S602 in the embodiment corresponding to FIG. 6.

The first sending unit 703 is configured to: after the first interactionunit 701 exchanges the clock synchronization packet with the first clocksource, and after the second interaction unit 702 exchanges the clocksynchronization packet with the second clock source, send a first clocksynchronization packet to a first slave clock of the network apparatus.

The first clock synchronization packet carries a first timestampgenerated by the network apparatus. A time indicated by the firsttimestamp is equal to a time that is of the first clock source and atwhich the network apparatus sends the first clock synchronizationpacket.

For example, the first sending unit 703 may perform S603. For a specificimplementation of the first sending unit 703, refer to the descriptionin the embodiment corresponding to FIG. 6, especially the descriptionabout S603 in the embodiment corresponding to FIG. 6.

The second sending unit 704 is configured to: after the firstinteraction unit 701 exchanges the clock synchronization packet with thefirst clock source, and after the second interaction unit 702 exchangesthe clock synchronization packet with the second clock source, send asecond clock synchronization packet to a second slave clock of thenetwork apparatus.

The first clock synchronization packet carries a second timestampgenerated by the network apparatus. A time indicated by the secondtimestamp is equal to a time that is of the second clock source and atwhich the network apparatus sends the second clock synchronizationpacket.

For example, the second sending unit 704 may perform S604. For aspecific implementation of the second sending unit 704, refer to thedescription in the embodiment corresponding to FIG. 6, especially thedescription about S604 in the embodiment corresponding to FIG. 6.

Optionally, in the foregoing technical solution, the network apparatus700 further includes a determining unit.

The determining unit is configured to: after the first interaction unit701 exchanges the clock synchronization packet with the first clocksource, determine a first time deviation of the network apparatusrelative to the first clock source according to the clocksynchronization packet exchanged with the first clock source, where thenetwork apparatus avoids performing an operation of calibrating a timeof a local clock of the network apparatus according to the first timedeviation.

The determining unit is further configured to determine that a value ofthe first timestamp is equal to a first corrected value, where the firstcorrected value is a value obtained by the network apparatus bycorrecting a time t1 of the local clock by using the first timedeviation, where the time t1 is a time at which the network apparatusgenerates the first timestamp.

For example, for a specific implementation of determining, by thenetwork apparatus, the first time deviation of the network apparatusrelative to the first clock source, refer to the description about theprocess of determining the first time deviation in the embodimentcorresponding to FIG. 3.

For example, for a specific process of determining the first correctedvalue by the network apparatus, refer to the description about theprocess of determining the first corrected value in the embodimentcorresponding to FIG. 3.

Optionally, in the foregoing technical solution, the determining unit isfurther configured to: after the first interaction unit 701 exchangesthe clock synchronization packet with the first clock source, determinea first frequency deviation of the network apparatus relative to thefirst clock source according to the clock synchronization packetexchanged with the first clock source, where the network apparatusavoids performing an operation of calibrating a frequency of the localclock according to the first frequency deviation, and the firstcorrected value is a value obtained by the network apparatus bycorrecting t1 by using the first time deviation and the first frequencydeviation.

For example, for a specific implementation of determining, by thenetwork apparatus, the first frequency deviation of the networkapparatus relative to the first clock source, refer to the descriptionabout the process of determining the first frequency deviation in theembodiment corresponding to FIG. 3.

For example, for a specific process of determining the first correctedvalue by the network apparatus, refer to the description about theprocess of determining the first corrected value in the embodimentcorresponding to FIG. 3.

Optionally, in the foregoing technical solution, the first correctedvalue is equal to a sum of t1, the first time deviation, and a firstphase deviation, and the first phase deviation is a phase deviation thatis of the local clock relative to the first clock source and that iscaused by the first frequency deviation within duration from a time atwhich the local clock determines the first frequency deviation to thetime at which the network apparatus generates the first timestamp.

For a specific implementation of how a frequency deviation causes aphase deviation, refer to the description in the embodimentcorresponding to FIG. 3, especially a the description about that 1 ppmcauses a phase deviation of 8 nanoseconds in the embodimentcorresponding to FIG. 3.

Optionally, a value of the second timestamp is determined in thefollowing manner:

after the second interaction unit 702 exchanges the clocksynchronization packet with the second clock source, determining, by thenetwork apparatus, a second time deviation of the network apparatusrelative to the second clock source according to the clocksynchronization packet exchanged with the second clock source, where thenetwork apparatus avoids performing an operation of calibrating the timeof the local clock of the network apparatus according to the second timedeviation; and

determining, by the network apparatus, that the value of the secondtimestamp is equal to a second corrected value, where the secondcorrected value is a value obtained by correcting a time t2 of the localclock by using the second time deviation, where the time t2 is a time atwhich the network apparatus generates the second timestamp.

Optionally, the value of the second timestamp is specifically determinedin the following manner:

after the second interaction unit 702 exchanges the clocksynchronization packet with the second clock source, determining, by thenetwork apparatus, a second frequency deviation of the network apparatusrelative to the second clock source according to the clocksynchronization packet exchanged with the second clock source, where thenetwork apparatus avoids performing an operation of calibrating thefrequency of the local clock of the network apparatus according to thesecond frequency deviation; and

determining, by the network apparatus, that the value of the secondtimestamp is equal to the second corrected value, where the secondcorrected value is a value obtained by the network apparatus bycorrecting t2 by using the second time deviation and the secondfrequency deviation.

Optionally, in the foregoing technical solution, the second correctedvalue is equal to a sum of t2, the second time deviation, and a secondphase deviation, and the second phase deviation is a phase deviationthat is of the local clock relative to the second clock source and thatis caused by the second frequency deviation within duration from a timeat which the local clock determines the second frequency deviation tothe time at which the network apparatus generates the second timestamp.

FIG. 8 is a schematic structural diagram of a system according to anembodiment of the present invention. The system 800 includes a networkapparatus 801, a first clock source 802, and a first slave clock 803.Specifically, the network apparatus 801 may be the network apparatus 500shown in FIG. 5. The first clock source 802 may be the first clocksource mentioned in the embodiment corresponding to FIG. 5. The firstslave clock 803 may be the first slave clock mentioned in the embodimentcorresponding to FIG. 5.

For specific implementations of the network apparatus 801, the firstclock source 802, and the first slave clock 803, refer to thedescription in the embodiment corresponding to FIG. 5.

Optionally, the system 800 may further include a second clock source 804and a second slave clock 805. Specifically, the second clock source 804may be the second clock source mentioned in the embodiment correspondingto FIG. 5. The second slave clock 805 may be the second slave clockmentioned in the embodiment corresponding to FIG. 5.

For specific implementations of the second clock source 804 and thesecond slave clock 805, refer to the description in the embodimentcorresponding to FIG. 5.

It should be understood that sequence numbers of the foregoing processesdo not mean execution sequences in various embodiments of thisapplication. The execution sequences of the processes should bedetermined according to functions and internal logic of the processes,and should not be construed as any limitation on the implementationprocesses of the embodiments of this application.

A person of ordinary skill in the art may be aware that, in combinationwith the examples described in the embodiments disclosed in thisspecification, units and steps may be implemented by electronic hardwareor a combination of computer software and electronic hardware. Whetherthe functions are performed by hardware or a combination of software andelectronic hardware depends on particular applications and designconstraint conditions of the technical solutions. A person skilled inthe art may use different methods to implement the described functionsfor each particular application, but it should not be considered thatthe implementation goes beyond the scope of this application.

It may be clearly understood by a person skilled in the art that, forthe purpose of convenient and brief description, for a detailed workingprocess of the foregoing system, apparatus, and unit, refer to acorresponding process in the foregoing method embodiments, and detailsare not described herein again.

In the several embodiments provided in this application, it should beunderstood that the disclosed system, apparatus, and method may beimplemented in other manners. For example, the described apparatusembodiment is merely an example. For example, the unit division ismerely logical function division and may be other division in actualimplementation. For example, a plurality of units or components may becombined or integrated into another system, or some features may beignored or not performed. In addition, the displayed or discussed mutualcouplings or direct couplings or communication connections may beimplemented by using some interfaces. The indirect couplings orcommunication connections between the apparatuses or units may beimplemented in electronic, mechanical, or other forms.

The units described as separate parts may or may not be physicallyseparate, and parts displayed as units may or may not be physical units,may be located in one position, or may be distributed on a plurality ofnetwork units. Some or all of the units may be selected according toactual requirements to achieve the objectives of the solutions of theembodiments.

In addition, functional units in the embodiments of this application maybe integrated into one processing unit, or each of the units may existalone physically, or two or more units are integrated into one unit. Theintegrated unit may be implemented in a form of hardware, or in a formof electronic hardware and software.

When the integrated unit is implemented in a form of a softwarefunctional unit and sold or used as an independent product, theintegrated unit may be stored in a computer-readable storage medium.Based on such an understanding, the technical solutions of thisapplication essentially, or the part contributing to the prior art, orsome of the technical solutions may be implemented in a form of asoftware product. The computer software product is stored in a storagemedium, and includes several instructions for instructing a processor ora computer device (which may be a personal computer, a server, a networkdevice, or the like) to perform all or some of the steps of the methodsdescribed in the embodiments of this application. The foregoing storagemedium includes: any medium that can store program code, such as a USBflash drive, a removable hard disk, a read-only memory (ROM), a randomaccess memory (RAM), a magnetic disk, or an optical disc.

What is claimed is:
 1. A method for exchanging a clock synchronizationpacket, comprising: exchanging, by a network apparatus, a clocksynchronization packet with a first clock source by using a first slaveport, wherein the network apparatus comprises a boundary clock (BC), andthe BC comprises the first slave port and a first master port;determining, by the network apparatus, a first time deviation of the BCrelative to the first clock source according to the clocksynchronization packet exchanged with the first clock source, whereinthe BC avoids performing an operation of calibrating a time of a localclock of the BC according to the first time deviation; and sending, bythe network apparatus, a clock synchronization packet to a first slaveclock of the BC by using the first master port, wherein the clocksynchronization packet sent by the network apparatus to the first slaveclock comprises a first timestamp generated by the BC, a value of thefirst timestamp is equal to a first corrected value, and the firstcorrected value is a value obtained by the BC by correcting a time t1 ofthe local clock by using the first time deviation, wherein the time t1is a time at which the BC generates the first timestamp.
 2. The methodaccording to claim 1, wherein after the exchanging, by a networkapparatus, a clock synchronization packet with a first clock source byusing a first slave port, and before the sending, by the networkapparatus, a clock synchronization packet to a first slave clock of theBC by using the first master port, the method further comprises:determining, by the network apparatus, a first frequency deviation ofthe BC relative to the first clock source according to the clocksynchronization packet exchanged with the first clock source, whereinthe BC avoids performing an operation of calibrating a frequency of thelocal clock of the BC according to the first frequency deviation, andthe first corrected value is a value obtained by the BC by correcting t1by using the first time deviation and the first frequency deviation. 3.The method according to claim 2, wherein the first corrected value isequal to a sum of t1, the first time deviation, and a first phasedeviation, and the first phase deviation is a phase deviation that is ofthe local clock relative to the first clock source and that is caused bythe first frequency deviation within duration from a time at which thelocal clock determines the first frequency deviation to the time atwhich the BC generates the first timestamp.
 4. The method according toclaim 1, wherein the method further comprises: exchanging, by thenetwork apparatus, a clock synchronization packet with a second clocksource by using a second slave port, wherein the BC comprises the secondslave port and a second master port; determining, by the networkapparatus, a second time deviation of the BC relative to the secondclock source according to the clock synchronization packet exchangedwith the second clock source, wherein the BC avoids performing anoperation of calibrating the time of the local clock of the BC accordingto the second time deviation; and sending, by the network apparatus, aclock synchronization packet to a second slave clock of the BC by usingthe second master port, wherein the clock synchronization packet sent bythe network apparatus to the second slave clock comprises a secondtimestamp generated by the BC, a value of the second timestamp is equalto a second corrected value, and the second corrected value is a valueobtained by correcting a time t2 of the local clock by using the secondtime deviation, wherein the time t2 is a time at which the BC generatesthe second timestamp.
 5. The method according to claim 4, wherein afterthe exchanging, by the network apparatus, a clock synchronization packetwith a second clock source by using a second slave port, and before thesending, by the network apparatus, a clock synchronization packet to asecond slave clock of the BC by using the second master port, the methodfurther comprises: determining, by the network apparatus, a secondfrequency deviation of the BC relative to the second clock sourceaccording to the clock synchronization packet exchanged with the secondclock source, wherein the BC avoids performing an operation ofcalibrating the frequency of the local clock of the BC according to thesecond frequency deviation, and the second corrected value is a valueobtained by the BC by correcting t2 by using the second time deviationand the second frequency deviation.
 6. The method according to claim 5,wherein the second corrected value is equal to a sum of t2, the secondtime deviation, and a second phase deviation, and the second phasedeviation is a phase deviation that is of the local clock relative tothe second clock source and that is caused by the second frequencydeviation within duration from a time at which the local clockdetermines the second frequency deviation to the time at which the BCgenerates the second timestamp.
 7. A network apparatus, comprising: atransceiver, configured to exchange a clock synchronization packet witha first clock source by using a first slave port, wherein the networkapparatus comprises a boundary clock (BC), and the BC comprises thefirst slave port and a first master port; a processor communicated withthe transceiver, configured to determine a first time deviation of theBC relative to the first clock source according to the clocksynchronization packet exchanged with the first clock source, whereinthe BC avoids performing an operation of calibrating a time of a localclock of the BC according to the first time deviation; and thetransceiver is further configured to send a clock synchronization packetto a first slave clock of the BC by using the first master port, whereinthe clock synchronization packet sent by the network apparatus to thefirst slave clock comprises a first timestamp generated by the BC, avalue of the first timestamp is equal to a first corrected value, andthe first corrected value is a value obtained by the BC by correcting atime t1 of the local clock by using the first time deviation, whereinthe time t1 is a time at which the BC generates the first timestamp. 8.The network apparatus according to claim 7, wherein the processor isfurther configured to: after the interaction unit exchanges the clocksynchronization packet with the first clock source by using the firstslave port, and before the sending unit sends the clock synchronizationpacket to the first slave clock of the BC by using the first masterport, determine a first frequency deviation of the BC relative to thefirst clock source according to the clock synchronization packetexchanged with the first clock source, wherein the BC avoids performingan operation of calibrating a frequency of the local clock of the BCaccording to the first frequency deviation, and the first correctedvalue is a value obtained by the BC by correcting t1 by using the firsttime deviation and the first frequency deviation.
 9. The networkapparatus according to claim 7, wherein the transceiver is furtherconfigured to exchange a clock synchronization packet with a secondclock source by using a second slave port, wherein the BC comprises thesecond slave port and a second master port; the processor is furtherconfigured to determine a second time deviation of the BC relative tothe second clock source according to the clock synchronization packetexchanged with the second clock source, wherein the BC avoids performingan operation of calibrating the time of the local clock of the BCaccording to the second time deviation; and the transceiver is furtherconfigured to send a clock synchronization packet to a second slaveclock of the BC by using the second master port, wherein the clocksynchronization packet sent by the network apparatus to the second slaveclock comprises a second timestamp generated by the BC, a value of thesecond timestamp is equal to a second corrected value, and the secondcorrected value is a value obtained by correcting a time t2 of the localclock by using the second time deviation, wherein the time t2 is a timeat which the BC generates the second timestamp.
 10. The networkapparatus according to claim 9, wherein the processor is furtherconfigured to: after the interaction unit exchanges the clocksynchronization packet with the second clock source by using the secondslave port, and before the sending unit sends the clock synchronizationpacket to the second slave clock of the BC by using the second masterport, determine a second frequency deviation of the BC relative to thesecond clock source according to the clock synchronization packetexchanged with the second clock source, wherein the BC avoids performingan operation of calibrating the frequency of the local clock of the BCaccording to the second frequency deviation, and the second correctedvalue is a value obtained by the BC by correcting t2 by using the secondtime deviation and the second frequency deviation.
 11. A method forexchanging a clock synchronization packet, comprising: exchanging, by anetwork apparatus, a clock synchronization packet with a first clocksource; exchanging, by the network apparatus, a clock synchronizationpacket with a second clock source; after the network apparatus exchangesthe clock synchronization packet with the first clock source and afterthe network apparatus exchanges the clock synchronization packet withthe second clock source, sending, by the network apparatus, a firstclock synchronization packet to a first slave clock of the networkapparatus, wherein the first clock synchronization packet carries afirst timestamp generated by the network apparatus, and a time indicatedby the first timestamp is equal to a time that is of the first clocksource and at which the network apparatus sends the first clocksynchronization packet; and after the network apparatus exchanges theclock synchronization packet with the first clock source and after thenetwork apparatus exchanges the clock synchronization packet with thesecond clock source, sending, by the network apparatus, a second clocksynchronization packet to a second slave clock of the network apparatus,wherein the second clock synchronization packet carries a secondtimestamp generated by the network apparatus, and a time indicated bythe second timestamp is equal to a time that is of the second clocksource and at which the network apparatus sends the second clocksynchronization packet.
 12. The method according to claim 11, wherein avalue of the first timestamp is determined in the following manner:after the network apparatus exchanges the clock synchronization packetwith the first clock source, determining, by the network apparatus, afirst time deviation of the network apparatus relative to the firstclock source according to the clock synchronization packet exchangedwith the first clock source, wherein the network apparatus avoidsperforming an operation of calibrating a time of a local clock of thenetwork apparatus according to the first time deviation; anddetermining, by the network apparatus, that the value of the firsttimestamp is equal to a first corrected value, wherein the firstcorrected value is a value obtained by the network apparatus bycorrecting a time t1 of the local clock by using the first timedeviation, wherein the time t1 is a time at which the network apparatusgenerates the first timestamp.
 13. The method according to claim 12,wherein the value of the first timestamp is specifically determined inthe following manner: after the network apparatus exchanges the clocksynchronization packet with the first clock source, determining, by thenetwork apparatus, a first frequency deviation of the network apparatusrelative to the first clock source according to the clocksynchronization packet exchanged with the first clock source, whereinthe network apparatus avoids performing an operation of calibrating afrequency of the local clock according to the first frequency deviation;and determining, by the network apparatus, that the value of the firsttimestamp is equal to the first corrected value, wherein the firstcorrected value is a value obtained by the network apparatus bycorrecting t1 by using the first time deviation and the first frequencydeviation.
 14. The method according to claim 13, wherein the firstcorrected value is equal to a sum of t1, the first time deviation, and afirst phase deviation, and the first phase deviation is a phasedeviation that is of the local clock relative to the first clock sourceand that is caused by the first frequency deviation within duration froma time at which the local clock determines the first frequency deviationto the time at which the network apparatus generates the firsttimestamp.
 15. A network apparatus, comprising: a first transceiver,configured to exchange a clock synchronization packet with a first clocksource; a second transceiver, configured to exchange a clocksynchronization packet with a second clock source; the first transceiveris further configured to: after the first interaction unit exchanges theclock synchronization packet with the first clock source and after thesecond interaction unit exchanges the clock synchronization packet withthe second clock source, send a first clock synchronization packet to afirst slave clock of the network apparatus, wherein the first clocksynchronization packet carries a first timestamp generated by thenetwork apparatus, and a time indicated by the first timestamp is equalto a time that is of the first clock source and at which the networkapparatus sends the first clock synchronization packet; and the secondtransceiver is further configured to: after the first interaction unitexchanges the clock synchronization packet with the first clock sourceand after the second interaction unit exchanges the clocksynchronization packet with the second clock source, send a second clocksynchronization packet to a second slave clock of the network apparatus,wherein the first clock synchronization packet carries a secondtimestamp generated by the network apparatus, and a time indicated bythe second timestamp is equal to a time that is of the second clocksource and at which the network apparatus sends the second clocksynchronization packet.
 16. The network apparatus according to claim 15,further comprising a processor, wherein the processor is configured to:after the first interaction unit exchanges the clock synchronizationpacket with the first clock source, determine a first time deviation ofthe network apparatus relative to the first clock source according tothe clock synchronization packet exchanged with the first clock source,wherein the network apparatus avoids performing an operation ofcalibrating a time of a local clock of the network apparatus accordingto the first time deviation; and the processor is further configured todetermine that a value of the first timestamp is equal to a firstcorrected value, wherein the first corrected value is a value obtainedby the network apparatus by correcting a time t1 of the local clock byusing the first time deviation, wherein the time t1 is a time at whichthe network apparatus generates the first timestamp.
 17. The networkapparatus according to claim 16, wherein the processor is furtherconfigured to: after the first interaction unit exchanges the clocksynchronization packet with the first clock source, determine a firstfrequency deviation of the network apparatus relative to the first clocksource according to the clock synchronization packet exchanged with thefirst clock source, wherein the network apparatus avoids performing anoperation of calibrating a frequency of the local clock according to thefirst frequency deviation, and the first corrected value is a valueobtained by the network apparatus by correcting t1 by using the firsttime deviation and the first frequency deviation.
 18. The networkapparatus according to claim 17, wherein the first corrected value isequal to a sum of t1, the first time deviation, and a first phasedeviation, and the first phase deviation is a phase deviation that is ofthe local clock relative to the first clock source and that is caused bythe first frequency deviation within duration from a time at which thelocal clock determines the first frequency deviation to the time atwhich the network apparatus generates the first timestamp.